package com.example.blogsystem.demos.service;

import com.example.blogsystem.demos.mapper.BlogInfoMapper;
import com.example.blogsystem.demos.model.BlogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    private BlogInfoMapper blogInfoMapper;

    public List<BlogInfo> queryBlogList(){
        List<BlogInfo> res = blogInfoMapper.queryBlogList();
        return res;
    }

    public BlogInfo queryBlogDetail(Integer id){
        BlogInfo res = blogInfoMapper.queryById(id);
        return res;
    }

    public Integer insertBlog(BlogInfo blogInfo) {
        if (blogInfo == null){
            return 0;
        }
        return blogInfoMapper.insertBlog(blogInfo);
    }

    public void updateBlog(BlogInfo blogInfo) {
        blogInfoMapper.updateBlog(blogInfo);
    }

    public Integer deleteBlog(Integer blogId) {
        return blogInfoMapper.deleteBlog(blogId);
    }
}
